package com.yfp.machine.service.impl;

import com.yfp.machine.domain.Position;
import com.yfp.machine.mapper.PositionMapper;
import com.yfp.machine.service.PositionService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * 点位表(Position)表服务实现类
 *
 *
 * @since 2023-12-21 20:51:19
 */
@Service("positionService")
public class PositionServiceImpl implements PositionService {
    @Resource
    private PositionMapper positionMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param positionId 主键
     * @return 实例对象
     */
    @Override
    public Position queryById(String positionId) {
        return this.positionMapper.queryById(positionId);
    }

    /**
     * 分页查询
     *
     * @param position 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Position> queryByPage(Position position) {
        return this.positionMapper.queryAllByLimit(position);
    }

    /**
     * 新增数据
     *
     * @param position 实例对象
     * @return 实例对象
     */
    @Override
    public Position insert(Position position) {
        this.positionMapper.insert(position);
        return position;
    }

    /**
     * 修改数据
     *
     * @param position 实例对象
     * @return 实例对象
     */
    @Override
    public Position update(Position position) {
        this.positionMapper.update(position);
        return this.queryById(position.getPositionId());
    }
}
